package com.jwsoft.manager.core.integration.eduAddressTree.impl;

import com.jwsoft.manager.common.vo.eduAddressTree.EduAddressTreeVO;
import com.jwsoft.manager.core.dao.service.EduAddressTreeSchoolService;
import com.jwsoft.manager.core.dao.service.EduAddressTreeService;
import com.jwsoft.manager.core.integration.eduAddressTree.AddressTreeObserver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 修正节点的叶子节点数和各学校的绑定叶子节点数
 *
 * @author fangs
 */
@Service
public class ReviseLeafNumTreeObserver implements AddressTreeObserver {
    @Autowired
    private EduAddressTreeService eduAddressTreeService;
    @Autowired
    private EduAddressTreeSchoolService eduAddressTreeSchoolService;

    @Override
    public void invoke(List<EduAddressTreeVO> changeList) {
        if (CollectionUtils.isEmpty(changeList)) {
            return;
        }
        ReviseLeafNumHandler reviseLeafNumHandler
                = new ReviseLeafNumHandler(changeList, eduAddressTreeService, eduAddressTreeSchoolService);
        reviseLeafNumHandler.handle();
    }
}
